﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerParent : MonoBehaviour
{
    /// <summary>
    /// FightScene
    /// </summary>
    private FightScene _fightScene;

    /// <summary>
    /// Awake
    /// </summary>
    private void Awake()
    {
        _fightScene = GameObject.Find("FightSceneRoot").GetComponent<FightScene>();
    }

    /// <summary>
    /// 碰撞检测
    /// </summary>
    /// <param name="other"></param>
    void OnTriggerEnter(Collider other)
    {
        string objectName = other.gameObject.name;
        Debug.Log("碰撞物体=" + objectName);
        //移动路段
        string[] array = objectName.Split('_');
        if (array[0] == "Plane")
        {
            Debug.Log("碰撞物体=" + objectName);
            int index = int.Parse(array[1]);
            _fightScene.generate_road(index);
        }

        //是障碍物
        if (array[0] == "ob")
        {
            _fightScene.collisionObstacle(objectName);
        }
    }
}